<?
//inculde即可以使用data数据。本页所有的data数据，倾在controller都处理好
include_once("../../../common/module/checkA.php");
include_once("../../../../config.php");
include_once("../controller/detail-list.php");
?>


<?$department_list=select_lines_all_items($table_Prefix."department","nid desc","","0");?>
<?

$employee_list=select_lines_all_items($table_Prefix."employee","nid desc","","0");
$new_employee_list=transform_2darray_in_1darray_with_new_key($employee_list,"nid","name");

$case_list=select_lines_all_items($table_Prefix."case","nid desc","","0");
$case_name_list=transform_2darray_in_1darray_with_new_key($case_list,"nid","name");

$unit_list=select_lines_all_items($table_Prefix."unit","nid desc","relation = '客户'","0");
$unit_name_list=transform_2darray_in_1darray_with_new_key($unit_list,"nid","name");

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <?php include ROOT_PATH_.'/controller/common/module/head.php'; ?>
    <?php include 'modules/head.php'; ?>
</head>

<body>

<div id="topbar">   <?php include ROOT_PATH_.'/controller/common/module/topbar.php'; ?></div>

<div id="container" class="finance">

    <div id="maincontent">

        <div id="sidebar">
            <?php include ROOT_PATH_.'/controller/common/module/sidebar.php'; ?>
        </div>


<div id="content" >
<h1> 财务汇总 </h1>



<? if(!in_array("finance",$quanxian)) {echo "没有权限";exit;} ?>


    <!-- 用$system_part .list_boxes来控制来到确认板块信息显示-->
<div class="list-box">



    <div class="statistic">







        <div class="select-box layui-form">
            <form action="detail-list.php" id="search">

                <div class="layui-form-item">
                    <label class="layui-form-label">关键词</label>
                    <div class="layui-input-block">
                        <input type="text" name="select_keywords" placeholder="可搜索姓名，备注，身份证，电话" autocomplete="off" class="layui-input" value="<? echo $_REQUEST['select_keywords']?>" >
                    </div>
                </div>






                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <select name="select_status">
                            <?//if($_REQUEST['select_status']){echo "<option value='".$_REQUEST['select_status']."'>".$_REQUEST['select_status']."</option>";}?>
                            <option value="">全部</option>
                            <option value="待收款" <? if($_REQUEST['select_status']=="待收款"){echo "selected";} ?>>待收款</option>
                            <option value="已收款" <? if($_REQUEST['select_status']=="已收款"){echo "selected";} ?>>已收款</option>
                            <option value="过账" <? if($_REQUEST['select_status']=="过账"){echo "selected";} ?>>过账</option>
                            <option value="其他" <? if($_REQUEST['select_status']=="其他"){echo "selected";} ?>>其他</option>
                        </select>
                    </div>
                </div>







                <button class="layui-btn">查找</button>

                <br class="clearfloat"/>
            </form>

            <br class="clearfloat"/>
        </div>








    </div>


<script>



</script>



    <div class="list-boxes layui-form">

<br class="clearfloat"/>





<table class="layui-table">
  <colgroup>
    <col width="100">
      <col >
      <col >
      <col width="150">
	<col > 
	<col > 
	<col >
	<col width="105">
	<col width="75">
	<col width="150">
	<col width="250">
  </colgroup>


    <style>
        .plgz{
            display: inline-block;
            height: 38px;
            line-height: 38px;
            padding: 0 18px;
            background-color: #009e94;
            color: #fff;
            white-space: nowrap;
            text-align: center;
            font-size: 14px;
            border: none;
            border-radius: 2px;
            cursor: pointer;
            opacity: .9;
            filter: alpha(opacity=90);
        }
        .plguozhang:hover{
            border-color: #009e94;
            color: #333;
        }
    </style>
    <form action="detail-piliangguozhang.php?&nowpageid=<?echo $nowpageid?>" method="post">
   

        <thead>
    <tr>

      <th><span onclick="quanxuan()">全选 </span>序号</th>
      <th>单位</th>
      <th>项目</th>
      <th>内容</th>
      <th>金额</th>
      <th>用款人</th>

      <th>类型</th>
      <th>日期</th>
      <th>状态</th>
      <th>备注</th>
      <th>操作</th>
    </tr> 
  </thead>
  <tbody>


  <?php
  if ($detailnum == 0) {
      echo "数据添加中";
  }

  ?>

  <?php
	for ($i = 0; $i < $detailnum; $i++) {
    ?>
        <!--//查看这条信息有无修改申请，有的话就变色，提示修改中-->
        <? $applymodify=select_one_line_all_items($table_Prefix."finance","rid='".$detail[$i]['nid']."' and applystatus='申请修改'") ;?>


<tr id="item<?echo $detail[$i]['nid']?>" <?if($applymodify['nid']){echo "style='color:red'";$status=" / 审核中";}else{$status="";}?>>

      <td>

          <?if(!$applymodify['nid']){?>



          <input name="plguozhang[<?echo $i?>]" type="checkbox" lay-skin="primary" value="<?echo $detail[$i]['nid']?>"><?echo $i+1+$plate['page_list_num']*($nowpageid-1) ?>

              <?;}?></td>

      <td><?echo $unit_name_list[$detail[$i]['unit']]?></td>

      <td><a href="../../case/view/detail-info.php?nid=<?echo $detail[$i]['caseid'] ?>" ><?echo $case_name_list[$detail[$i]['caseid']]?></a></td>

      <td><?echo $detail[$i]['name']?></td>
      <td><?echo $detail[$i]['cost']?></td>
      <td><?echo $new_employee_list[$detail[$i]['principal']]?></td>


	  <td><?echo $detail[$i]['classify']?></td>
	  <td><?echo substr($detail[$i]['applydate'],0,10)?></td>
	  <td> <?echo $detail[$i]['status']?></td>
	  <td >
          <? if(($detail[$i]['remark'])and($detail[$i]['remark']!="  ")){ ?>
          <span id="reamrk_<?php echo $detail[$i]['nid']?>" onmouseover="show_remark ('<?php echo $detail[$i]['remark']?>','reamrk_<?php echo $detail[$i]['nid']?>')" >
              <?
              $conditon['str']=$detail[$i]['remark'];
              $conditon['len']=8;
              $conditon['from']=0;
              echo utf8_substr($conditon)."..."?></span>
          <?;}?>

      </td>
	  <td>






<?

if($detail[$i]['status']!="过账")
{//情况分为过账和未过账，过账表示已经落实该财务信息，所有人都不能修改



//在过账的情况下，出纳或者管理员权限才显示的菜单 和 普通财务权限的显示菜单


//出纳或者管理员权限才显示的菜单
if (in_array("teller",$quanxian) || in_array("admin",$quanxian) )
{

//出纳或者管理员权限才能删除
if($applymodify['nid'])
{?>
<a href="detail-verify.php?nav-itemed=<?echo $system_part?>&nid=<? echo $detail[$i]['nid']?>" class="layui-btn layui-btn-primary layui-btn-small">审核修改</a>
<?;}
    else
    {//审核中的财务信息不能删除，不能修改，不能过账
        ?>
        <a href="detail-edit.php?nav-itemed=<?echo $system_part?>&nid=<? echo $detail[$i]['nid']?>&nowpageid=<?echo $nowpageid?>"
           class="layui-btn  layui-btn-sm" >
            <i class="layui-icon">&#xe642;</i>修改</a>


        <a href="javascript:void(0)" onclick="delItem (<?php echo $detail[$i]['nid']?>)"
           class="delete layui-btn  layui-btn-sm" > <i class="layui-icon">&#xe640;</i> 删除 </a>




        <a href="javascript:void(0)" onclick="verifystatus('<? echo $detail[$i]['nid']?>')"
           class="layui-btn  layui-btn-sm" id="item-function-<?echo $detail[$i]['nid']?>">

            <?
            if($detail[$i]['status']!="过账"){echo "过账";}
            else{echo "取消过账";}
            ?>
        </a>




        <?
    }?>

<?;}//出纳或者管理员权限才显示的菜单

else{
if(!$applymodify['nid']){?>
<!-- 普通员工修改-->
<a href="detail-add-edit.php?nav-itemed=<?echo $system_part?>&nid=<? echo $detail[$i]['nid']?>&nowpageid=<?echo $nowpageid?>"
   class="layui-btn  layui-btn-xs" >
  <i class="layui-icon">&#xe642;</i>修改
<?}
else{
    echo "审核中";
};}?>





<?;}//情况分为过账和未过账，过账表示已经落实该财务信息，所有人都不能修改
else
{//此处为未过账的情况
if (in_array("teller",$quanxian) || in_array("admin",$quanxian) )
{?>




    <a href="javascript:void(0)" onclick="verifystatus('<? echo $detail[$i]['nid']?>')"
       class="layui-btn  layui-btn-xs" "
       id="item-function-<?echo $detail[$i]['nid']?>">

        <?
        if($detail[$i]['status']!="过账"){echo "过账";}
        else{echo "取消过账";}
        ?>
    </a>


<?}?>
<?}?>







  </td> 
    </tr>
    <?}?>

 
  </tbody>
    </form>
</table>




 

</div>


<div class="list-box-function" <? if ($detailnum == 0) {
    echo "style" . "='display:none'";
} ?> >
    <div class="page-guide">

        <?php
        if ($nowpageid == 1) {
            ?>
            <!--现在页数在第一页的时候-->
            <span>首页</span>
            <span>前一页</span>
            <!--现在页数非第一页的时候-->
        <?php
        } else {
            ?>
            <!--现在页数非第一页的时候-->
            <a href="detail-list.php?sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&sys_part=<? echo $system_part ?>&nav-itemed=<?echo $_GET["nav-itemed"]?>">首页</a>
            <a href="detail-list.php?nowpageid=<?php echo $prepage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&sys_part=<? echo $system_part ?>&nav-itemed=<?echo $_GET["nav-itemed"]?>">前一页</a>
            <!--现在页数非第一页的时候-->
        <?php
        }
        ?>


        <!--开始列印出所有页码-->

        <?php
        $ii = 1;
        $iii = 1;

        while ($ii <= $page_count) {
            //首先判断是不是当前页

            if ($ii == $nowpageid) {
                echo "<span>" . $ii . "</span>";
            } else if ((($ii + 5) < $nowpageid) || (($ii - 5) > $nowpageid)) {
            } else {
                echo "<a href='";
                echo "detail-list.php?nowpageid=";
                echo $iii;
                echo "&sortby=";
                echo $sort_by;
                echo "&nid=";
                echo $trans_nid;
                echo "&sys_part=";
                echo $system_part;
                echo $url_str;
                echo "&nav-itemed=";
                echo $_GET['nav-itemed'];
                echo "'>";
                echo $iii;
                echo "</a>";
            }

            $ii++;
            $iii++;
        }
        ?>

        <!--列印出所有页码 结束-->


        <?php
        if ($nowpageid == $page_count) {
            ?>
            <!--现在页数在第一页的时候-->
            <span>后一页</span>
            <span>末页</span>
            <!--现在页数非第一页的时候-->
        <?php
        } else {
            ?>
            <!--现在页数非第一页的时候-->
            <a href="detail-list.php?nowpageid=<?php echo $nextpage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&sys_part=<? echo $system_part ?>&nav-itemed=<?echo $_GET["nav-itemed"]?>">后一页</a>
            <a href="detail-list.php?nowpageid=<?php echo $lastpage; ?>&sortby=<?php echo $sort_by; ?>&nid=<?php echo $trans_nid ?>&sys_part=<? echo $system_part ?>&nav-itemed=<?echo $_GET["nav-itemed"]?>">末页</a>
            <!--现在页数非第一页的时候-->
        <?php
        }
        ?>


    </div>
    <!--翻页代码结束-->
</div>


<!--list-boxes end-->
</div>
<!--list-box end-->
</div>

<!--content端點01-->
</div>
<!--maincontent端點01-->
<br class="clearfloat"/>
</div>
<!--container端點01-->
</div>



<?php include ROOT_PATH_ . "/controller/common/module/footer.php"; ?>




</body>
</html>




<script>

    layui.use('form', function(){
        var form = layui.form;


        form.on('select()', function(data){
            //提交表单
            document.getElementById("search").submit();

        });



    });

    function quanxuan(){
        var name= $("table input[type=checkbox]").next();
        if(name.attr("class")=="layui-unselect layui-form-checkbox") {
            name.attr("class", "layui-unselect layui-form-checkbox layui-form-checked");
            $("table input[type=checkbox]").attr("checked",true);
        }
        else{
            name.attr("class", "layui-unselect layui-form-checkbox");
            $("table input[type=checkbox]").attr("checked",false);

        }
    }





    <!--改变过账状态的函数-->
    function verifystatus (id) {


        $newstatus=$('#item-function-'+id).text();
        $newstatus=$.trim($newstatus);
        if($newstatus=="取消过账"){$newstatus="待审核";}


//传递id为数据的id，并且移除的时候会删除元素item+id

        //先问一下是否删除

        //显现遮罩图层
        $(".message_layer").css({ 'display':'block'});
        //锁定页面高度
        $("body").height($(window).height()).css({
            "overflow-y": "hidden"
        });


        //ajax删除数据
        $.get('detail-verify-status.php?nid='+id+'&tellerstatus='+$newstatus,null,function (msg) {//ajax请求,请求后执行下面代码


            msg=$.trim(msg);

            //删除遮罩图层



            if ('1'==msg) {//返回1表示成功


                //$('#item-function-'+id).remove();//把id为txx 的表格删除

                if($newstatus=="过账"){$buttontxt="取消过账"}
                else{$buttontxt="过账"}

                location.reload()

                $('#item-function-'+id).text($buttontxt);
                $('#list-status-'+id).text($newstatus);


//隐藏遮罩图层并解锁页面高度
                $("body").css({'height':'','overflow':'auto'});
                $(".message_layer").css({ 'display':'none'});


            } else {//否则弹出错误信息
                alert("更新审核状态失败");

                //隐藏遮罩图层并解锁页面高度
                $("body").css({'height':'','overflow':'auto'});
                $(".message_layer").css({ 'display':'none'});
            }
        });

    }





</script>
